bitkeeper revision 1.1010.1.2 (40daf234LK7ohaP4f1QHGPJq0t3yZw)
authormjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>
Thu, 24 Jun 2004 15:24:36 +0000 (15:24 +0000)
committermjw@wray-m-3.hpl.hp.com <mjw@wray-m-3.hpl.hp.com>
Thu, 24 Jun 2004 15:24:36 +0000 (15:24 +0000)
Change configs to live in /etc/xen, other stuff in /var/xen.
Update xendomains to use xm.

tools/examples/Makefile
tools/examples/init.d/xendomains
tools/xenmgr/lib/XendBridge.py
tools/xenmgr/lib/XendRoot.py
tools/xenmgr/lib/xm/create.py
tools/xenmgr/lib/xm/shutdown.py

index ed8e4c71b121e6a9f90f9ce2e10ddcd6305c8160..3f7075ed1dc0bc727f8c9ae2d7ca3df558bad00a 100644 (file)
@@ -1,19 +1,20 @@
 
 INSTALL  = $(wildcard *.py)
 ETC     = defaults democd netbsd xmdefaults
+ETCDIR   = /etc/xen
 INITD    = init.d/xendomains init.d/xend
 
 all: 
 
 install: all
        mkdir -p $(prefix)/usr/bin
-       mkdir -p $(prefix)/etc/xc
-       mkdir -p $(prefix)/etc/xc/auto
+       mkdir -p $(prefix)$(ETCDIR)
+       mkdir -p $(prefix)$(ETCDIR)/auto
        mkdir -p $(prefix)/etc/init.d
        install -m0755 $(INSTALL) $(prefix)/usr/bin
        for i in $(ETC); \
-           do [ -a $(prefix)/etc/xc/$$i ] || \
-           install -m0644 $$i $(prefix)/etc/xc; \
+           do [ -a $(prefix)/$(ETCDIR)/$$i ] || \
+           install -m0644 $$i $(prefix)$(ETCDIR); \
        done
        install -m0755 $(INITD) $(prefix)/etc/init.d
 
index fa96ff8378374f3a931502479120261a704ad8de..41524e6f5740f307e7cf5614ad2d234e15902cee 100755 (executable)
@@ -19,6 +19,9 @@ RETVAL=0
 
 INITD=/etc/init.d/
 
+AUTODIR=/etc/xen/auto
+LOCKFILE=/var/lock/subsys/xendomains
+
 if [ -e /lib/lsb ]; then
     # assume an LSB-compliant distro (Debian with LSB package,
     # recent-enough SuSE, others...)
@@ -52,24 +55,23 @@ fi
 
 
 start() {
-    if [ -f /var/lock/subsys/xendomains ]; then return; fi
+    if [ -f $LOCKFILE ]; then return; fi
 
     echo -n $"Starting auto Xen domains:"
 
-    # we expect config scripts for auto starting domains to be in
-    # /etc/xc/auto/ - they could just be symlinks to files elsewhere
-    if [ -d /etc/xc/auto ] &&
-           [ $(ls /etc/xc/auto/ | wc -l) -gt 0 ]; then
+    # We expect config scripts for auto starting domains to be in
+    # AUTODIR - they could just be symlinks to files elsewhere
+    if [ -d $AUTODIR ] && [ $(ls $AUTODIR | wc -l) -gt 0 ]; then
+       touch $LOCKFILE
        
-       # create all domains with config files in /etc/xc/auto
-       for dom in /etc/xc/auto/*; do
-           xc_dom_create.py -q -f $dom
+       # Create all domains with config files in AUTODIR.
+       for dom in  $AUTODIR/*; do
+           xm create --quiet --defaults $dom
            if [ $? -ne 0 ]; then
                RETVAL=$?
            fi
        done
 
-       touch /var/lock/subsys/xendomains
     fi
 
     on_fn_exit
@@ -78,40 +80,24 @@ start() {
 stop()
 {
     # NB. this shuts down ALL Xen domains (politely), not just the ones in
-    # /etc/xc/auto/*
+    # AUTODIR/*
     # This is because it's easier to do ;-) but arguably if this script is run
     # on system shutdown then it's also the right thing to do.
     
     echo -n $"Shutting down all Xen domains:"
 
-    if [ -d /var/run/xendomains ] &&
-           [ $(ls /var/run/xendomains/ | wc -l) -gt 0 ]; then
-       
-       cd /var/run/xendomains/
-
-       for pid in *; do
-          
-           kill -s SIGTERM $(cat $pid)
-
-       done
+    xm shutdown --all --wait --norestart
 
-    fi
-
-    sleep 3 # avoid races
-
-    xc_dom_control.py shutdown all -w # shut down all domains, politely and wait
-                                      # for all to exit
-    
     RETVAL=$?
 
-    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xendomains
+    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
 
     on_fn_exit
 }
 
 # This does NOT necessarily restart all running domains: instead it
 # stops all running domains and then boots all the domains specified in
-# /etc/xc/auto.  If other domains have been started manually then they will
+# AUTODIR.  If other domains have been started manually then they will
 # not get restarted.
 # Commented out to avoid confusion!
 #
@@ -149,7 +135,7 @@ case "$1" in
 #      ;;
 
     status)
-       xc_dom_control.py list
+       xm list
        ;;
 
     *)
index 1be802477d363e38c3c2b7a1077c35a57a23e59b..3ea16d57bf91e03bfcecb398d40074c90084a3de 100644 (file)
@@ -12,6 +12,7 @@ os.defpath = os.defpath + ':/sbin:/usr/sbin:/usr/local/sbin'
 CMD_IFCONFIG = 'ifconfig'
 CMD_ROUTE    = 'route'
 CMD_BRCTL    = 'brctl'
+CMD_IPTABLES = "iptables"
 
 DEFAULT_BRIDGE = 'nbe-br'
 DEFAULT_INTERFACE = 'eth0'
@@ -61,6 +62,16 @@ def vif_bridge_rem(dom, vif, bridge=None):
     d = { 'bridge': bridge, 'vif': vif_dev(dom, vif) }
     cmd(CMD_BRCTL, 'delif %(bridge)s %(vif)s' % d)
 
+def vif_restrict_addr(dom, vif, addr, delete=0):
+    d = { 'vif': vif_dev(dom, vif), 'addr': addr}
+    if delete:
+        d['flag'] = '-D'
+    else:
+        d['flag' = '-A'
+    cmd(CMD_IPTABLES, '-P FORWARD DROP')
+    cmd(CMD_IPTABLES, '%(flag)s FORWARD -m physdev --physdev-in %(vif)s -s %(addr)s -j ACCEPT' % d)
+    cmd(CMD_IPTABLES, '%(flag)s FORWARD -m physdev --physdev-out %(vif)s -d %(addr)s -j ACCEPT' % d)
+
 def bridge_create(bridge=None, **kwd):
     """Create a bridge.
     Defaults hello time to 0, forward delay to 0 and stp off.
index 6d9903a91d20dcf2887e80c2cad27d45628bbeb2..665f5df29ee2747f43170baa49618f6082f50e7b 100644 (file)
@@ -30,13 +30,13 @@ def last_reboot():
 class XendRoot:
     """Root of the management classes."""
 
-    lastboot_default = "/etc/xen/xend/lastboot"
+    lastboot_default = "/var/xen/lastboot"
 
     """Default path to the root of the database."""
-    dbroot_default = "/etc/xen/xend/xenmgr-db"
+    dbroot_default = "/var/xen/xend-db"
 
     """Default path to the config file."""
-    config_default = "/etc/xen/xenmgr-config.sxp"
+    config_default = "/etc/xen/xend-config.sxp"
 
     """Environment variable used to override config_default."""
     config_var     = "XEND_CONFIG"
index e3ccad20b7b012053245521fe0f481d1937a7de5..3d4165d1f2a16fea026808db0404be77628217d7 100644 (file)
@@ -24,11 +24,11 @@ gopts.opt('quiet', short='q',
          use="Quiet.")
 
 gopts.opt('path', val='PATH',
-         fn=set_value, default='.:/etc/xc',
+         fn=set_value, default='.:/etc/xen',
          use="Search path for default scripts.")
 
 gopts.opt('defaults', short='f', val='FILE',
-         fn=set_value, default='xmdefaults',
+         fn=set_value, default='defaults',
          use="Use the given default script.")
 
 gopts.opt('config', short='F', val='FILE',
@@ -220,12 +220,13 @@ def configure_vifs(config_devs, opts):
             config_vif.append(['bridge', bridge])
         config_devs.append(['device', config_vif])
 
-##     if vfr_ipaddr:
-##         config_vfr = ['vfr']
-##         idx = 0 # No way of saying which IP is for which vif?
-##         for ip in vfr_ipaddr:
-##             config_vfr.append(['vif', ['id', idx], ['ip', ip]])
-##         config.append(config_vfr)
+def configure_vfr(config, opts):
+     if not opts.ipaddr: return
+     config_vfr = ['vfr']
+     idx = 0 # No way of saying which IP is for which vif?
+     for ip in opts.ipaddr:
+         config_vfr.append(['vif', ['id', idx], ['ip', ip]])
+     config.append(config_vfr)
 
 
 def make_config(opts):
index 90fff21f6ad6d03514673e30ca32cf1481ec370b..7cdcc6310596bfa36cb28bba49c679b9013126b3 100644 (file)
@@ -24,6 +24,10 @@ gopts.opt('wait', short='w',
          fn=set_true, default=0,
          use='Wait for shutdown to complete.')
 
+gopts.opt('norestart', short='n',
+          fn=set_true, default=0,
+          use='Prevent domain restart.')
+
 def shutdown(opts, doms, wait):
     def domains():
         return [ int(a) for a in server.xend_domains() ]